package com.example.shujujiegousuanfa.链表;

/**
 * 判断链表是否有段，如果有，返回环的长度和入口点
 * 结果类：
 * 是否有环
 * 环的长度
 * 入口点
 */
class CircleResult {
    boolean haveCircle; // 是否有环
    int circleLength;   // 环的长度
    MyLinkedList.Node entryNode; // 环的入口

    private CircleResult(Builder builder) {
        haveCircle = builder.haveCircle;
        circleLength = builder.circleLength;
        entryNode = builder.entryNode;
    }

    public static final class Builder {
        private boolean haveCircle;
        private int circleLength;
        private MyLinkedList.Node entryNode;

        public Builder() {
        }

        public Builder haveCircle(boolean val) {
            haveCircle = val;
            return this;
        }

        public Builder circleLength(int val) {
            circleLength = val;
            return this;
        }

        public Builder entryNode(MyLinkedList.Node val) {
            entryNode = val;
            return this;
        }

        public CircleResult build() {
            return new CircleResult(this);
        }
    }
}
